package com.gitee.ywj1352.算法.week02;

import java.util.ArrayList;
import java.util.List;

public class 电话号码的字母组合 {


    public static List<String> getAll(char[] chars1, char[] chars2) {
        List<String> res = new ArrayList<>();
        doGetAll(chars1, chars2, 0, "", res);
        return res;
    }


    public static void doGetAll(char[] chars1, char[] chars2, int level, String s, List<String> res) {
        if (level == 1) {
            for (int i = 0; i < chars2.length; i++) {
                res.add(s + chars2[i]);
            }
            return;
        }
        for (int i = 0; i < chars1.length; i++) {
            doGetAll(chars1, chars2, level + 1, s+ chars1[i], res);
        }
    }


    public static void main(String[] args) {
        char[] arr1 = {'1', '2', '3'};
        char[] arr2 = {'a', 'b', 'c'};
        List<String> all = getAll(arr1, arr2);

        for (String arr : all) {
            System.out.println(arr);
        }

    }

}
